﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.EntityClient;
using System.Data.Entity;

namespace Budgeter.Models
{

    public class BudgeterContext : Entities
    {

        public BudgeterContext(string providerName, string providerConnectionString)
            : base(CreateEntityFrameworkConnectionString(providerName, providerConnectionString))
        { }

        private static string CreateEntityFrameworkConnectionString(string providerName, string providerConnectionString)
        {
            EntityConnectionStringBuilder entityBuilder =
                new EntityConnectionStringBuilder();

            entityBuilder.Provider = providerName;
            entityBuilder.ProviderConnectionString = providerConnectionString;
            entityBuilder.Metadata = @"res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl";

            string connectionString = entityBuilder.ToString();
            return connectionString;
        }

    }

    // Plug in a connectionString constructor to the generated DbContext subclass

    public partial class Entities
    {

        public Entities(string connectionString)
            : base(connectionString)
        { }

    }

}
